/* eslint-disable prefer-arrow-callback */
var injectWebViewJavascriptBridge = function (callback) {
	if (window.WebViewJavascriptBridge) {
		return callback(window.WebViewJavascriptBridge);
	}
	if (window.WVJBCallbacks) {
		return window.WVJBCallbacks.push(callback);
	}
	window.WVJBCallbacks = [callback];
	var WVJBIframe = document.createElement('iframe');
	WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__';
	WVJBIframe.style.display = 'none';
	document.body.appendChild(WVJBIframe);
	setTimeout(function () {
		document.body.removeChild(WVJBIframe);
	}, 0);
	document.addEventListener('WebViewJavascriptBridgeReady', function () {
		callback(window.WebViewJavascriptBridge);
	}, false);
};
var injectWebViewJavascriptBridgeCallback = function (bridge) {
	bridge.registerHandler('getH5Info', function (data, callback) {
		callback(JSON.stringify({
			'code': 1,
			'name': '获取H5信息',
			'data': {
				'userAgent': navigator.userAgent
			}
		}));
	});
};
injectWebViewJavascriptBridge(injectWebViewJavascriptBridgeCallback);
